#include "basics.h"

class CRay {
private:

	float mag;          // the magnitude of our ray
	Vector3 direction;  // direction of our ray
	Vector3 origin;     // tail of the ray
	Vector3 head;       // end of the ray
	bool dirty;		    // recalculate the head

	void CalculatePoint(); // calculate the head of the ray

public:
	CRay(Vector3, float);
	CRay(Vector3, Vector3, float);

	// -- accessors
	Vector3 GetHead();
	Vector3 GetTail();

	// -- mutators
	void SetMagnitude(float t);
	void SetDirection(Vector3 dir);
}; 


// =================================================================================================
// Constructor for the ray
// =================================================================================================
inline CRay::CRay(Vector3 direction_, float mag_) : mag(mag_), direction(direction_), dirty(true) {
}

inline CRay::CRay(Vector3 direction_, Vector3 origin_, float mag_) : mag(mag_), 
	                                                                 direction(direction_), 
	                                                                 dirty(true), origin(origin_){
}


// =================================================================================================
// Mutators
// =================================================================================================
inline void CRay::SetMagnitude(float t) {
	dirty = true;
	mag = t;
}

inline void CRay::SetDirection(Vector3 dir) {
	dirty = true;
	direction = dir;
}

// =================================================================================================
// Accessor
// =================================================================================================
inline Vector3 CRay::GetTail() {
	return origin;
}